<?php
/*
*   案例列表页
*/
header('Location: /');
  $special_categories=get_terms('case',array('hide_empty'=> false,'orderby'=>'id','order'=>'ASC',));
  get_header();
  //if(have_posts()):the_post();
  get_sidebar('pagenav'); //调用页面导航
  
?>

<!-- 美丽相册11111 -->
<div id="caselist">
   <ul class="p">
		<?php
			$paged_view = $_GET['paged_view']?$_GET['paged_view']:1;//判断是否首次加载页面
			$args=array(
				'post_type' => 'cases',
				'posts_per_page' =>2,
				'paged' =>$paged_view,
				'meta_key' => 'rank',
				'orderby'  => array('meta_value_num' => 'DESC', 'date' => 'DESC'),
			);
			$query = new WP_Query( $args);
			while($query->have_posts()):$query->the_post();
		?>
        <li>
            <div class="mainContent">
                <div class="case_item_left">
                    <img src="<?php the_field('headimg'); ?>" alt="" class="headerimg">
                    <p class="name"><?php the_field('name'); ?><br><span><?php the_field('qianming'); ?></span></p>
                </div>
                <div class="cf"></div>
                <div class="plasticDiary">
                    <div class="plastleftimg">
                        <a href="<?php the_permalink() ?>">
                            <img src="<?php the_field('ago_img'); ?>" alt="" class="plast_photo">
                        </a>
                    </div>
                    <div class="plastrightimg">
                        <a href="<?php the_permalink() ?>">
                            <img src="<?php the_field('after_img'); ?>" alt="" class="plast_photo">
                        </a>
                    </div>
                    <div class="cf"></div>
                    <p class="plast_title"><?php echo strip(get_field('zllc_word')); ?></p>
                    <ul>
                        <a href="javascript:void(0);" onclick="openZoosUrl();"><li><?php the_field('project_have_done'); ?></li></a>
                    </ul>
                </div>
            </div>

            <div class="album_line"></div>
        </li>
		<?php
			endwhile;
			wp_reset_query();
		?>
    </ul>
</div>
<div class="bot_line">
    <div class="click_more">点击查看更多</div>
</div>

<script type="text/javascript">
jQuery(document).ready(function($) {
  //点击下一页的链接(即那个a标签)   
  var paged_view=2;
  $('.click_more').click( function() {   
    $this = $(this);
    $this.html("Loading...");
    $.ajax( { //发起ajax请求   
        url: "?action=ajax&paged_view="+paged_view, //请求的地址就是下一页的链接   
        type: "get", //请求类型是get   
     error: function(request) {   
         //如果发生错误怎么处理   
     },   
     success: function(data) { //请求成功
        if(paged_view<=<?php echo $query->max_num_pages;?>){
			var $res = $(data).find("ul.p>li"); //从数据中挑出文章数据，请根据实际情况更改 
			$('ul.p').append($res); //将数据加载加进posts-loop的标签中。
			$this.html("加载更多");
			//console.log(data);
			paged_view++;
        }else{
          $('.click_more').html("没有更多内容了");
        }
     }   
     });  
   });      
 });  
</script>

<?php
 // endif;
  get_footer();
?>